package com.brainhealth.customer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.brainhealth.common.annotation.Log;
import com.brainhealth.common.core.controller.BaseController;
import com.brainhealth.common.core.domain.AjaxResult;
import com.brainhealth.common.enums.BusinessType;
import com.brainhealth.customer.domain.ScoreMallOrderDetail;
import com.brainhealth.customer.service.IScoreMallOrderDetailService;
import com.brainhealth.common.utils.poi.ExcelUtil;
import com.brainhealth.common.core.page.TableDataInfo;

/**
 * 积分商城订单明细表Controller
 * 
 * @author wolong
 * @date 2023-11-01
 */
@RestController
@RequestMapping("/customer/mallOrderDetail")
public class ScoreMallOrderDetailController extends BaseController
{
    @Autowired
    private IScoreMallOrderDetailService scoreMallOrderDetailService;

    /**
     * 查询积分商城订单明细表列表
     */
    @PreAuthorize("@ss.hasPermi('customer:mallOrderDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScoreMallOrderDetail scoreMallOrderDetail)
    {
        startPage();
        List<ScoreMallOrderDetail> list = scoreMallOrderDetailService.selectScoreMallOrderDetailList(scoreMallOrderDetail);
        return getDataTable(list);
    }

    /**
     * 导出积分商城订单明细表列表
     */
    @PreAuthorize("@ss.hasPermi('customer:mallOrderDetail:export')")
    @Log(title = "积分商城订单明细表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScoreMallOrderDetail scoreMallOrderDetail)
    {
        List<ScoreMallOrderDetail> list = scoreMallOrderDetailService.selectScoreMallOrderDetailList(scoreMallOrderDetail);
        ExcelUtil<ScoreMallOrderDetail> util = new ExcelUtil<ScoreMallOrderDetail>(ScoreMallOrderDetail.class);
        util.exportExcel(response, list, "积分商城订单明细表数据");
    }

    /**
     * 获取积分商城订单明细表详细信息
     */
    @PreAuthorize("@ss.hasPermi('customer:mallOrderDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scoreMallOrderDetailService.selectScoreMallOrderDetailById(id));
    }

    /**
     * 新增积分商城订单明细表
     */
    @PreAuthorize("@ss.hasPermi('customer:mallOrderDetail:add')")
    @Log(title = "积分商城订单明细表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScoreMallOrderDetail scoreMallOrderDetail)
    {
        return toAjax(scoreMallOrderDetailService.insertScoreMallOrderDetail(scoreMallOrderDetail));
    }

    /**
     * 修改积分商城订单明细表
     */
    @PreAuthorize("@ss.hasPermi('customer:mallOrderDetail:edit')")
    @Log(title = "积分商城订单明细表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScoreMallOrderDetail scoreMallOrderDetail)
    {
        return toAjax(scoreMallOrderDetailService.updateScoreMallOrderDetail(scoreMallOrderDetail));
    }

    /**
     * 删除积分商城订单明细表
     */
    @PreAuthorize("@ss.hasPermi('customer:mallOrderDetail:remove')")
    @Log(title = "积分商城订单明细表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scoreMallOrderDetailService.deleteScoreMallOrderDetailByIds(ids));
    }
}
